$(function() {
		$(".scroller").slimscroll({
			height : $(window).height() - 200 + "px"
		});
		$("#simscoll2").slimscroll({
			height : $(window).height() - 100 + "px"
		});

		var date = new Date();
		$(".datetime").html(
				date.getFullYear() + "-" + date.getMonth() + 1 + "-"
						+ date.getDate() + " " + date.getHours() + ":"
						+ date.getMinutes());
		$("#butsearch").on('click',function() {
							var ly = cmm.layerLoad();
							$.ajax({
										url : "${ctx}/sys/svm/ichat",
										data : {
											id : $(".act").attr("data-id"),
											name : $("#anwer").val()
										},
										type : "post",
										dataType : "json",
										success : function(d, v, s) {
											cmm.layerClose(ly);
											if (d != null && d.code == "200") {
												var div = '<li class="out"><img class="avatar img-responsive" alt="" src="${ctx}/resources/img/fi2.jpg">';
												div += '<div class="message">';
												div += '<span class="arrow"></span> <a href="javascript:;" class="name">我</a> ';
												div+='<span class="datetime">'+date.getFullYear() + "-" + date.getMonth() + 1 + "-"
												+ date.getDate() + " " + date.getHours() + ":"
												+ date.getMinutes()+'</span> ';
												div+='<span class="body">'+$("#anwer").val()+'</span>';
												div += '</div></li>';
												$("#anwer").val("");
												$(".chats").append(div);
												
											}
										},
										timeout : 30000,
										error : function(d, v) {
											cmm.layerClose(ly);
										}
									})
						});
		getData();
	});
	
	function swjg(data){
		var div='<li class="in"><img class="avatar img-responsive" alt="" src="${ctx}/resources/img/zxs2.png" />';
		div+='<div class="message">';
		div+='	<span class="arrow" style="font-family: 微软雅黑; font-size: 14px"></span> <a href="javascript:;" class="name">智能客服</a> <span class="datetime">'+	date.getFullYear() + "-" + date.getMonth() + 1 + "-"
		+ date.getDate() + " " + date.getHours() + ":"
		+ date.getMinutes()+'</span> <span class="body">'+data.data+' </span>';
	    div+='</div></li>';
	    $(".chats").append(div);
	}
	
	function getData() {
		var ly = cmm.layerLoad();
		$.ajax({
					url : "${ctx}/sys/nlp/listcode",
					data : {},
					type : "post",
					dataType : 'json',
					success : function(data, sv) {
						cmm.layerClose(ly);
						var dd = data.rows;
						if (dd != null) {
							for (var i = 0; i < dd.length; i = i + 4) {
								var act = dd[i].id == "1" ? "act" : "";
								var div = '<li class="modellv '
										+ act
										+ '" style="cursor: pointer;" data-id="'
										+ dd[i].id + '">';
								div += '<div class="col1">';
								div += dd[i].name;
								div += '</div>';
								div += '</li>';
								$(".feeds").append($(div));
							}
							var div = '<li class="modellv '
									+ '" style="cursor: pointer;" data-id="'
									+ "2" + '">';
							div += '<div class="col1">';
							div += "ceshi";
							div += '</div>';
							div += '</li>';
							$(".feeds").append($(div));
							$(".modellv").on("click", function(e) {
								var t = $(this);
								$(".modellv").each(function() {
									$(this).removeClass("act");
								});
								t.addClass("act");
							});
						}
					},
					timeout : 60000,
					error : function(data, sv) {
						cmm.layerClose(ly);
					}
				});

	}